<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<html>
<head>
    <title>购物车</title>
    <% String path = request.getContextPath();%>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript" src="<%=path%>/js/jquery-1.11.min.js"></script>
    <script type="text/javascript" src="<%=path%>/js/etao.js"></script>
    <script type="text/javascript" src="<%=path%>/js/cart.js"></script>
    <link href="/css/cart.css" media="screen" rel="stylesheet" type="text/css" />
    <link type="text/css" rel="stylesheet" type="text/css" href="/css/bootstrap.min.css"  media="screen"  />


    <link rel="stylesheet" type="text/css" href="/css/slick.css"/>
<%--    <link rel="stylesheet" type="text/css" href="/css/bootstrap.css"/>--%>
    <link rel="stylesheet" type="text/css" href="/css/jquery.mmenu.all.css"/>
    <link rel="stylesheet" type="text/css" href="/css/style.css"/>
    <link rel="stylesheet" type="text/css" href="/css/jquery.mCustomScrollbar.css"/>
    <link rel="stylesheet" href="http://cdn.bootcss.com/animate.css/3.5.1/animate.min.css">
<%--    <script type="text/javascript" src="<%=path %>/js/jquery.min.js"></script>--%>
<%--    <script type="text/javascript" src="<%=path %>/js/jquery.easyui-1.5.1.min.js"></script>--%>
<%--    <script type="text/javascript" src="<%=path %>/js/themes/insdep/jquery.insdep-extend.min.js"></script>--%>
<%--&lt;%&ndash;    <script src="http://apps.bdimg.com/libs/html5shiv/r29/html5.min.js"></script>&ndash;%&gt;--%>
<%--    <script src="http://apps.bdimg.com/libs/respond.js/1.4.2/respond.min.js"></script>--%>


    <link rel="shortcut icon" href="/images/favicon.ico">
    <!-- include main css -->
    <link href="/css/cart.css" media="screen" rel="stylesheet" type="text/css" />



</head>
<body class="container">
<script>
    //到首页
    function tomain() {
        $.ajax({
            url:"/user/index",
            type:"post",
            data:"",
            datatype:"text",
            async:false,
            success:function () {
                window.location.href  = "/user/index";
            },
            error:function () {
                window.location.href="/user/index";
            }
        })

    }

    //去查看订单
    function toOrders(){
        $.ajax({
            url:"order/myorders",
            type:"post",
            data:"",
            datatype:"text",
            async:false,
            success:function(){
                window.location.href = "/order/myorders";
            },
            error:function () {
                window.location.href = "/order/myorders";

            }
        })
    }

    //进购物车
    function tocart() {
        $.ajax({
            url:"/cart/tocart",
            type:"post",
            data:"",
            datatype:"text",
            async:false,
            success:function () {
                window.location.href = "/cart/tocart";
            },
            error:function () {
                window.location.href="/cart/tocart";
            }
        })
    }
    //进商城
    function toShopping() {
        $.ajax({
            url:"/mall/shopping/0",
            type:"post",
            data:"",
            datatype:"text",
            async:false,
            success:function () {
                window.location.href="/mall/shopping/0";
            },
            error:function () {
                window.location.href="/mall/shopping/0";
            }
        })
    }

</script>

<header class="header">
    <section class="container naver clearfix">
        <div class="logo pull-left"><a href="index.html" title="花卉销售系统" alt="花卉销售系统"></a></div>
        <nav class="nav pull-left">
            <ul>
                <li ><a onclick="tomain()" >首页</a></li>
                <li><a onclick="toShopping()">商城</a>
                </li>
                <li><a class="active"onclick="tocart()" > 购物车 </a>
                </li>
                <li><a  onclick="toOrders()"> 查看订单 </a>
                    <%--						<ul>--%>
                    <%--							<li><a href="contact.html">联系我们</a></li>--%>
                    <%--							<li><a href="message.html">在线留言</a></li>--%>
                    <%--							<li><a href="job.html">人才招聘</a></li>--%>
                    <%--						</ul>--%>
                </li>
            </ul>
        </nav>

        <div class="language pull-right clearfix">
            <div class="language_wrap">
                <a href="#">EN</a>
                <a href="#">CN</a>
            </div>
            <span>种植园花卉售卖系统</span>
        </div>
    </section>
</header>

<div class="row hidden-print">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <ol class="breadcrumb">
            <li><a onclick="tomain()">首页</a></li>
            <li class="active">查看购物车</li>
        </ol>
    </div>
</div>
<div class="cart-wrap">
    <table id="cartTable" class="cart table table-condensed">
        <thead>
        <tr>
            <th class="t-checkbox"><label><input class="check-all check" type="checkbox" />全选</label></th>
            <th class="t-goods text-center"><label>花卉编号</label></th>
            <th class="text-center">产品备注</th>
            <th class="t-selling-price text-center"><label>销售单价</label></th>
            <th class="t-qty text-center"><label>采购数量</label></th>
            <th class="t-subtotal text-center"><label>金额小计</label></th>
            <th class="t-action"><label>操作</label></th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${orderList}" var="order">
            <tr>
                <td colspan="3" class="goods"><label> <input type="checkbox" class="check-one check" />${order.flowerId}</label></td>
                <td>无</td>
                <td class="selling-price number small-bold-red text-right"
                    style="padding-top: 1.1rem;" data-bind="${order.flowerprice}">${order.flowerprice}</td>
                <td>
                    <div class="input-group input-group-sm">
                        <span class="input-group-addon minus">-</span>
                            <input type="text" class="number form-control input-sm" value="${order.customerOrderQuantity}"/>
                        <span class="input-group-addon plus">+</span>
                    </div>
                </td>
                <td class="subtotal number small-bold-red text-right" style="padding-top: 1.1rem;">${order.customerOrderMoney}</td>
                <td class="action" style="padding-top: 1.1rem;"><button class="delete btn btn-xs btn-warning" onclick="deleteorder('${order.customerOrderId}')">删除</button></td>
            </tr>
        </c:forEach>
        <script type="text/javascript">
<%--            删除订单--%>
            function deleteorder(id) {
                $.ajax({
                    url:"<%=path%>/cart/deleteorderingoods",
                    type:"post",
                    data:{cOid:id},
                    dataType:"json",
                    async:false,
                    success:function(data){
                        if(data.status == "20000"){
                            alert("删除成功")
                        }
                    },
                    error:function(){
                        $.messager.alert("error","注册失败，请联系管理员");
                    }
                })
            }
        </script>
        </tbody>
    </table>

    <div class="row">
        <div class="col-md-12 col-lg-12 col-sm-12">
            <div class="cart-summary">
                <div style="margin-left: 2rem;" class="pull-right">
                    <input id="btn_settlement" type="button" class="btn btn-primary" onclick="toConfitm()" disabled value="去结算" >
                </div>
                <div style="margin-left: 1rem; margin-top: 0.4rem;" class="pull-right total">
                    金额合计:<label id="money"><span id="priceTotal" class="price-total large-bold-red">0.00</span></label>
                </div>
                <div style="margin-top: 10px;" class="pull-right">
                    <label>您选择了<span id="itemCount" class="large-bold-red" style="margin: 0 4px;"></span>种花朵，共计<span id="qtyCount" class="large-bold-red" style="margin: 0 4px;"></span>件
                    </label>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    function toConfitm() {
        var pricetotal = document.getElementById('money').innerText;
        <%--alert(pricetotal);--%>
        <%--alert('${orderList[0].customerId}')--%>

        $.ajax({
            url:"confirm",
            type:"post",
            data:{"allmoney":pricetotal,"userid":'${orderList[0].customerId}'},
            // data:{"cid":cid,"number":number,"iid":iid},
            datatype:"text",
            async:false,
            success:function () {
                window.location.href ="tocartconfim"
            },
            error:function () {
                // window.location.href ="cart/confirm"
            }
        })
    }
</script>


</html>